package com.chenkun.dao;

import com.chenkun.pojo.JobInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by chenkun on 2017/5/14.
 */
@Mapper
public interface JobDao {

    @Select("select * from job_info WHERE overdue_date >= curdate()")
    public List<JobInfo> getAllUsefullJobs();

    @Insert("insert into job_info(code,top_code,type_code,name,short_name,use_date,overdue_date,remark) values(#{code},#{top_code},#{type_code},#{name},#{short_name},#{use_date},#{overdue_date},#{remark})")
    public int insert(JobInfo jobInfo);

    @Delete("delete from job_info where code =#{code} and overdue_date >= curdate() ")
    public int delete(int code);

    @Update("update job_info set code=#{code},top_code=#{top_code},type_code=#{type_code},name=#{name},short_name=#{short_name},use_date=#{use_date},overdue_date=#{overdue_date} where id =#{id}")
    public int update(JobInfo jobInfo);

    @Select("select * from job_info where top_code =#{top_code}")
    public List<JobInfo> getByTopCode(int top_code);

    @Select("select * from job_info where id = #{id}")
    public JobInfo getById(int id);

    @Select("select * from job_info")
    public List<JobInfo> getAll();

    @Select("select * from job_info where code =#{code} and overdue_date >=curdate() ")
    public JobInfo getJobByCode(int code);
}
